package com.terabits.smartriver;

import com.terabits.smartriver.netty.config.NettyServer;
import org.apache.catalina.filters.CorsFilter;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

/**
 * Created by Yin on 2019/2/11
 */
@EnableCaching
@EnableScheduling
@SpringBootApplication

public class SmartriverApplication implements CommandLineRunner, DisposableBean {
    @Autowired
    NettyServer nettyServer;

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(SmartriverApplication.class);
        springApplication.setBannerMode(Banner.Mode.CONSOLE);
        springApplication.run(args);
    }


    @Override
    public void run(String... args) throws Exception {
        nettyServer.start();
        System.out.println("netty启动" + args);

    }

    @Override
    public void destroy() throws Exception {
        System.out.println("netty关闭");
        nettyServer.stop();
    }

}

